#!/bin/bash
set -x
if [[ "$1" = "-m" ]] ; then
  multiple="$2"
  shift 2
fi
it=0
ic=0
while (( $# > 0 )) ; do
    if (( ic < multiple )) ; then
      dirs[$ic]=$1
      (( ic = ic + 1 ))
    else
      if (( it < multiple )) ; then
        ic=0
        $i/stdload.sh -a -x $it ${dirs[*]} &
        (( it = it + 1 ))
      else
        wait
        it=0
      fi
    fi
done
